package br.com.fiap.beans;

import java.util.ArrayList;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean(name="quiz")
@SessionScoped
public class QuizzSimples {

    private ArrayList<Problema> problemas = new ArrayList<Problema>();
    private String resposta;
    private int score = 0;
    private int nQuestao = 0;


    public int getScore() {
        return score;
    }
    public QuizzSimples(){
        problemas.add(new Problema("{3,1,4,1}",5));
        problemas.add(new Problema("{0,1,0,1}",0));
        problemas.add(new Problema("{1,1,2,3}",5));
        problemas.add(new Problema("{2,2,4,8}",16));
        problemas.add(new Problema("{a,1,d,4,h}",8));
        problemas.add(new Problema("{u,5,e,2,i}",3));
    }   

    public String getSequencia(){
        if(nQuestao>=problemas.size()){
            nQuestao=0;
        }
        return problemas.get(nQuestao).getSequencia();
    }

    public String getResposta(){
        return resposta;
    }

    public void setResposta(String resposta){
        if(resposta.equals(String.valueOf(problemas.get(nQuestao++).getSolução()))){
            score++;
        }
    }
}
